﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using BLL;
using DAL;
using Models;
using System.Data;
using Web.Old_App_Code;
using System.Collections;



public partial class cn_online_message : System.Web.UI.Page
{

    protected MessageReplyManager mrm = new MessageReplyManager();
    protected string order = "id";
    protected int ot = 1;
    protected int pageCount = 0;
    protected int pageIndex = 1;
    protected int pageSize = 10;
    protected PageList pl = new PageList();
    protected PageListManager plm = new PageListManager();
    protected int total = 0;

    // Methods
    protected StringBuilder OnlineMessageBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["p"] != null)
            {
                this.pageIndex = Convert.ToInt32(base.Request.QueryString["p"]);
            }
            this.pl.TblName = "tb_onlineMessage";
            this.pl.StrGetFields = "id,messageUser,title,[content],messageTime";
            this.pl.PageSize = this.pageSize;
            this.pl.PageIndex = this.pageIndex;
            this.pl.DoCount = 1;
            this.pl.FldName = this.order;
            this.pl.OrderType = this.ot;
            this.pl.StrWhere = "isShow=1 and languageVersion='zh-CN'";
            this.total = Convert.ToInt32(this.plm.GetPageList(this.pl).Rows[0]["Total"]);
            this.pl.DoCount = 0;
            DataTable pageList = this.plm.GetPageList(this.pl);
            builder.AppendLine("<div class=\"tabcontain\">");
            builder.AppendLine("<ul class=\"comment_list\">");
            foreach (DataRow row in pageList.Rows)
            {
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<h5>", row["messageUser"], "：<strong>", row["title"], "</strong> <span>", Convert.ToDateTime(row["messageTime"]).ToString("yyyy-MM-dd HH:mm:ss"), "</span></h5>" }));
                builder.AppendLine("<p>" + row["content"] + "</p>");
                DataTable messageReplyById = this.mrm.GetMessageReplyById(Convert.ToInt32(row["id"]));
                if (messageReplyById.Rows.Count > 0)
                {
                    builder.AppendLine("<div>");
                    foreach (DataRow row2 in messageReplyById.Rows)
                    {
                        builder.AppendLine("<h6>管理员回复：</h6>");
                        builder.AppendLine("<p>" + row2["replyContent"] + "</p>");
                    }
                    builder.AppendLine("<p class=\"last\">共有<strong>" + messageReplyById.Rows.Count + "</strong>条回答</p>");
                    builder.AppendLine("</div>");
                }
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine(new PageListNo().FrontDeskDisplayPage(this.total, this.pageSize, this.pageIndex).ToString());
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}